# 创建一个背景为蓝色天空的Pygame窗口

import sys
import pygame

from settings import Settings
from blackbird import BlackBird

class BlueSkyGame:
    def __init__(self):
        pygame.init()

        self.clock = pygame.time.Clock()

        self.settings = Settings()
        # 创建一个显示窗口
        self.screen = pygame.display.set_mode((self.settings.screen_width,
                                               self.settings.screen_height))
        pygame.display.set_caption("Blue Sky Game")

        self.bbird = BlackBird(self)

    def run_game(self):
        while True:
            self._check_events()
            self._update_screen()
            
            self.clock.tick(60)

    def _check_events(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    def _update_screen(self):
        # 设置背景颜色
        self.screen.fill(self.settings.bg_color)
        self.bbird.blitme()

        pygame.display.flip()


if __name__ == '__main__':
    bsg = BlueSkyGame()
    bsg.run_game()